interface UseMessageProps {
    handleSendMessage: (...e: any) => void;
    handleAcceptMessage: (...e: any) => void;
}

const useMessage = (): UseMessageProps => {
    /**
     *
     * @param name 事件名称
     * @param data 传递的数据 json格式
     */
    const handleSendMessage = (name = "", data = {}) => {
        //@ts-ignore
        window.ReactNativeWebView.postMessage(JSON.stringify({name, data}));
    };
    const handleAcceptMessage = () => {};

    return {
        handleSendMessage,
        handleAcceptMessage,
    };
};

export default useMessage;
